{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "from scipy.stats import norm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# z_score for sampling distributions\n",
    "\n",
    "def z_score(sample_size, sample_mean, pop_mean, pop_std):\n",
    "    numerator = sample_mean - pop_mean\n",
    "    denomenator = pop_std / sample_size**0.5\n",
    "    return numerator / denomenator"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Understanding the Hypothesis Testing"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Step - 1:  \n",
    "Alternate Hypothesis (Bold claim): $ H_1 \\ \\Rightarrow \\ >, \\ <, \\ \\neq  $  \n",
    "Null Hypothesis (Status Quo): $ H_0 \\ \\Rightarrow \\ \\leq, \\ \\geq, \\ = $\n",
    "\n",
    "Step - 2:  \n",
    "* Collect a sample of size n\n",
    "* Compute the mean from this sample $ \\bar{x} $\n",
    "\n",
    "Step - 3:\n",
    "Compute Test Statistic:  \n",
    "* If population variance is known $$ z = \\frac{\\bar{x} - \\mu}{\\sigma/\\sqrt[2]{n}}$$\n",
    "\n",
    "* If population variance is unknown $$ t = \\frac{\\bar{x} - \\mu}{s/\\sqrt[2]{n}} $$\n",
    "\n",
    "Step - 4:\n",
    "Decide significance level $ \\alpha $. Lower $ \\alpha $ means you need stronger evidence to reject Null Hypothesis.\n",
    "\n",
    "Step - 5.1: Apply decision rule:\n",
    "* If test statistic is z-score -\n",
    "    * Two tailed z-test: $$ |z| > z_\\frac{\\alpha}{2} \\Rightarrow Accept \\ H_1 \\ or \\ Reject \\ H_0$$\n",
    "    * Right tailed z-test: $$ z > z_\\alpha \\Rightarrow Accept \\ H_1 \\ or \\ Reject \\ H_0 $$\n",
    "    * Left tailed z-test: $$ z < -z_\\alpha \\Rightarrow Accept \\ H_1 \\ or \\ Reject \\ H_0 $$\n",
    "    \n",
    "* If test statistic is t-score\n",
    "    * Two tailed t-test: $$ |t| > t_{n-1,\\frac{\\alpha}{2}} \\Rightarrow Accept \\ H_1 \\ or \\ Reject \\ H_0 $$\n",
    "    * Right tailed t-test: $$ t > t_{n-1,\\alpha} \\Rightarrow Accept \\ H_1 \\ or \\ Reject \\ H_0 $$\n",
    "    * Left tailed t-test: $$ t < t_{n-1,\\alpha} \\Rightarrow Accept \\ H_1 \\ or \\ Reject \\ H_0 $$\n",
    "\n",
    "Step - 5.2: Compute p-value $ P(Test \\ Statistics | H_0) $\n",
    "* For two tailed test: $$ p \\ value = 2 * (1.0 - cdf(test \\ statistic)) $$\n",
    "* For one tailed test: $$ p \\ value = (1.0 - cdf(test \\ statistic)) $$\n",
    "Now, $$ if (p \\ value < \\alpha) \\Rightarrow Accept \\ H_1 \\ or \\ Reject \\ H_0 $$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Known Variance of Population"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<b>Q-1: Pista House selling Hyderabadi Chicken Dum biryani claims that each parcel packet has 500 grams of biryani (also mentioned on the label of packet). You are sceptic of their claims and believe that on average each packet does not contain 500 grams of biryani. How do you prove your claim? (Given that the population std is 50) </b>\n",
    "\n",
    "\n",
    "Step - 1:  \n",
    "Alternate Hypothesis (Bold claim): $$ H_1: \\ ? $$\n",
    "Null Hypothesis (Status Quo): $$ H_0: \\ ? $$\n",
    "\n",
    "Step - 2:  \n",
    "* Collect a sample of size n = 10 $$ [490, 220, 470, 500, 495, 496, 496, 498, 508, 480] $$\n",
    "* Compute sample mean $$ \\bar{x} \\ = \\ ? $$\n",
    "\n",
    "Step - 3:\n",
    "Compute Test Statistic: $$ z = \\frac{\\bar{x} - \\mu}{\\sigma/\\sqrt[2]{n}}$$\n",
    "\n",
    "Step - 4:\n",
    "Decide $ \\alpha $ or significance level\n",
    "\n",
    "Step - 5.1: ? tailed z-test: $$ reject \\ H_0 \\ if \\ ? $$\n",
    "\n",
    "Step - 5.2: Compute p-value\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "465.3"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "l = [490, 220, 470, 500, 495, 496, 496, 498, 508, 480]\n",
    "\n",
    "sum(l)/len(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Defining the sample and population parameters\n",
    "\n",
    "sample_size = 10\n",
    "sample_mean = 465.3\n",
    "pop_mean = 500\n",
    "pop_std = 50"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-2.1946206961568544\n"
     ]
    }
   ],
   "source": [
    "# Calculating the z-score\n",
    "\n",
    "z = z_score(sample_size, sample_mean, pop_mean, pop_std)\n",
    "\n",
    "print(z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.959963984540054\n"
     ]
    }
   ],
   "source": [
    "# Two Tail - Calculating the z-critical value\n",
    "\n",
    "confidence_level = 0.95\n",
    "\n",
    "alpha = 1 - confidence_level\n",
    "\n",
    "z_critical = norm.ppf(1 - alpha/2) # Two tailed Z score for 95% Confidence Level\n",
    "\n",
    "print(z_critical)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(465.3, 0.0007, 'x_bar')"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAD4CAYAAADy46FuA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]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Ploting the sampling distribution with rejection regions\n",
    "\n",
    "# Defining the x minimum and x maximum\n",
    "x_min = 400\n",
    "x_max = 600\n",
    "\n",
    "\n",
    "# Defining the sampling distribution mean and sampling distribution std\n",
    "mean = pop_mean\n",
    "std = pop_std / sample_size**0.5\n",
    "\n",
    "\n",
    "# Ploting the graph and setting the x limits\n",
    "x = np.linspace(x_min, x_max, 100)\n",
    "y = norm.pdf(x, mean, std)\n",
    "plt.xlim(x_min, x_max)\n",
    "plt.plot(x, y)\n",
    "\n",
    "\n",
    "# Computing the left and right critical values (Two tailed Test)\n",
    "z_critical_left = pop_mean + (-z_critical * std)\n",
    "z_critical_right = pop_mean + (z_critical * std)\n",
    "\n",
    "\n",
    "# Shading the left rejection region\n",
    "x1 = np.linspace(x_min, z_critical_left, 100)\n",
    "y1 = norm.pdf(x1, mean, std)\n",
    "plt.fill_between(x1, y1, color='orange')\n",
    "\n",
    "\n",
    "# Shading the right rejection region\n",
    "x2 = np.linspace(z_critical_right, x_max, 100)\n",
    "y2 = norm.pdf(x2, mean, std)\n",
    "plt.fill_between(x2, y2, color='orange')\n",
    "\n",
    "\n",
    "# Ploting the sample mean and concluding the results \n",
    "plt.scatter(sample_mean, 0)\n",
    "plt.annotate(\"x_bar\", (sample_mean, 0.0007))\n",
    "\n",
    "\n",
    "# In this case sample mean falls in the rejection region\n",
    "# i.e. here we reject the Null Hypothesis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Reject Null Hypothesis\n"
     ]
    }
   ],
   "source": [
    "# Conclusion using z test\n",
    "\n",
    "if(np.abs(z) > z_critical):\n",
    "    print(\"Reject Null Hypothesis\")\n",
    "else:\n",
    "    print(\"Fail to reject Null Hypothesis\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "p_value =  0.028190817687629988\n",
      "Reject Null Hypothesis\n"
     ]
    }
   ],
   "source": [
    "# Conclusion using p test\n",
    "\n",
    "p_value = 2 * (1.0 - norm.cdf(np.abs(z)))\n",
    "\n",
    "print(\"p_value = \", p_value)\n",
    "\n",
    "if(p_value < alpha):\n",
    "    print(\"Reject Null Hypothesis\")\n",
    "else:\n",
    "    print(\"Fail to reject Null Hypothesis\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<b>Q-2: You have developed a new Natural Language Processing Algorithms and done a user study. You claim that the average rating given by the users is greater than 4 on a scale of 1 to 5. How do you prove this to your client? (Given that the population std is 0.5)</b>\n",
    "\n",
    "Step - 1:  \n",
    "Alternate Hypothesis (Bold Claim): $$ H_1: \\ ? $$\n",
    "Null Hypothesis (Status Quo): $$ H_0: \\ ? $$\n",
    "\n",
    "Step - 2:  \n",
    "* Collect a sample of size n = 20 $$ [4, 3, 5, 4, 5, 3, 5, 5, 4, 2, 4, 5, 5, 4, 4, 5, 4, 5, 4, 5] $$\n",
    "* Compute sample mean $$ \\bar{x} \\ = \\ ? $$\n",
    "\n",
    "Step - 3:\n",
    "Compute Test Statistic: $$ z = \\frac{\\bar{x} - \\mu}{\\sigma/\\sqrt[2]{n}}$$\n",
    "\n",
    "Step - 4:\n",
    "Decide $ \\alpha $\n",
    "\n",
    "Step - 5.1: ? tailed z-test: $$ reject \\ H_0 \\ if ? $$\n",
    "\n",
    "Step - 5.2: Compute p-value\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4.25"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "l = [4,3,5,4,5,3,5,5,4,2,4,5,5,4,4,5,4,5,4,5]\n",
    "\n",
    "sum(l)/len(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Defining the sample and population parameters\n",
    "\n",
    "sample_size = 20\n",
    "sample_mean = 4.25\n",
    "pop_mean = 4\n",
    "pop_std = 0.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2.23606797749979\n"
     ]
    }
   ],
   "source": [
    "# Calculating the z-score\n",
    "\n",
    "z = z_score(sample_size, sample_mean, pop_mean, pop_std)\n",
    "\n",
    "print(z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.6448536269514722\n"
     ]
    }
   ],
   "source": [
    "# One Tail - Calculating the z-critical value\n",
    "\n",
    "confidence_level = 0.95\n",
    "\n",
    "alpha = 1 - confidence_level\n",
    "\n",
    "z_critical = norm.ppf(1 - alpha)\n",
    "\n",
    "print(z_critical)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(4.25, 0.1, 'x_bar')"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAsI0lEQVR4nO3dd3xU15n/8c8zM+oVoS7RTBNIIMAyBtuJCzEGxzbYSxKXJE7iDcHrTbJJfulZZ+O0zXrTXGLWcRzbiWPHBXeqCwYbU0QRSKKJroYkQA31mfP7YwYsywKNxEh3yvN+vebFzNyjma8u0qM75557jhhjUEopFfhsVgdQSinlG1rQlVIqSGhBV0qpIKEFXSm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xc8Hyfn2xSHgSmPMKRGZj/vkYKjuC0TEDvwG97TifiPoj9CNW7PnYZjn1vNM8O3AMmPMUc/X1AxhxCHj5b4wQJy4F1ONBU4CXUOXcuiISDbwaeCxczQ5u/i5549eoohkDFnAIdTXvjDGbDDGnPI83Ih7VbKg5MXPBcDXgRcBv6oVQV/Q4ezHpx24d/4aY8ymHk0mAMNEZK2IbBWRLw55yCHixb54CJiEewnBXcA3jTGuoU05ZP4AfA841/d3rsXPg9EfOP++6O4uYMWgprHWHzjPvhCRLOBmYGlv260UEgXdGOM0xkzDfVQxU0TyejRxABfj/qt8HfCfIjJhaFMODS/2xXXADiATmAY8JCK9fuwMZCJyA1BjjDnngrt4ufh5oPNyX5xpezXugv79QQ9mAS/3xR+A7xtjnEOTynshUdDPMMbUA2uBeT02lQMrjTGnjTF1wDogqE/6nGdffBl395MxxpTh7jvNGdp0Q+Jy4CYROQw8C1wjIn/v0SZUFj/3Zl8gIlNxd0MsMMacGNqIQ8abfVEAPOtpswj4k4gsHMqQ52SMCeobkAIkeu5HAeuBG3q0mQS8hftIPRooBvKszm7RvngE+C/P/TSgAki2Ovsg75ergNd7ef7TuLsWBJgFbLY6q4X7YiTuNYMvszqj1fuiR5sngEVWZz1zC4VRLhnAk56z0jbgOWPM690XuTbG7BaRlcBO3P1mjxljiq2LPGj63BfAz4EnRGQX7kL2feP+1BISdPHzD/XYF/cCw3EfjQJ0GT+eddDXeuwLv6WX/iulVJAIqT50pZQKZlrQlVIqSGhBV0qpIKEFXSmlgoQWdKWUChJa0JVSKkhoQVdKqSDx/wEVz+awLP2umQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Ploting the sampling distribution with rejection regions\n",
    "\n",
    "# Defining the x minimum and x maximum\n",
    "x_min = 3.5\n",
    "x_max = 4.5\n",
    "\n",
    "\n",
    "# Defining the sampling distribution mean and sampling distribution std\n",
    "mean = pop_mean\n",
    "std = pop_std / (sample_size**0.5)\n",
    "\n",
    "\n",
    "# Ploting the graph and setting the x limits\n",
    "x = np.linspace(x_min, x_max, 100)\n",
    "y = norm.pdf(x, mean, std)\n",
    "plt.xlim(x_min, x_max)\n",
    "plt.plot(x, y)\n",
    "\n",
    "\n",
    "# Computing the right critical value (Right tailed Test)\n",
    "z_critical_right = pop_mean + (z_critical * std)\n",
    "\n",
    "\n",
    "# Shading the right rejection region\n",
    "x1 = np.linspace(z_critical_right, x_max, 100)\n",
    "y1 = norm.pdf(x1, mean, std)\n",
    "plt.fill_between(x1, y1, color='orange')\n",
    "\n",
    "\n",
    "# Ploting the sample mean and concluding the results \n",
    "plt.scatter(sample_mean, 0)\n",
    "plt.annotate(\"x_bar\", (sample_mean, 0.1))\n",
    "\n",
    "# In this case sample mean falls in the rejection region\n",
    "# i.e. Reject the Null Hypothesis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Reject Null Hypothesis\n"
     ]
    }
   ],
   "source": [
    "# Conclusion using z test\n",
    "\n",
    "if(z > z_critical):\n",
    "    print(\"Reject Null Hypothesis\")\n",
    "else:\n",
    "    print(\"Fail to reject Null Hypothesis\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "p_value =  0.0126736593387341\n",
      "Reject Null Hypothesis\n"
     ]
    }
   ],
   "source": [
    "# Conclusion using p test\n",
    "\n",
    "p_value = 1.0 - norm.cdf(np.abs(z))\n",
    "\n",
    "print(\"p_value = \", p_value)\n",
    "\n",
    "if(p_value < alpha):\n",
    "    print(\"Reject Null Hypothesis\")\n",
    "else:\n",
    "    print(\"Fail to reject Null Hypothesis\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<b>Q-3: TATA has developed a better fuel management system for the SUV segment. They claim that with this system, on average the SUV's mileage is at least 15 km/litre? (Given that the population std is 1)</b>\n",
    "\n",
    "Step - 1:  \n",
    "Alternate Hypothesis (Bold Claim): $$ H_1: \\ ? $$\n",
    "Null Hypothesis (Status Quo): $$ H_0: \\ ? $$\n",
    "\n",
    "Step - 2:  \n",
    "* Collect a sample of size n = 20 $$ [14.08, 14.13, 15.65, 13.78, 16.26, 14.97, 15.36, 15.81, 14.53, 16.79, 15.78, 16.98, 13.23, 15.43, 15.46, 13.88, 14.31, 14.41, 15.76, 15.38] $$\n",
    "* Compute sample mean $$ \\bar{x} \\ = \\ ? $$\n",
    "\n",
    "Step - 3:\n",
    "Compute Test Statistic: $$ z = \\frac{\\bar{x} - \\mu}{\\sigma/\\sqrt[2]{n}}$$\n",
    "\n",
    "Step - 4:\n",
    "Decide $ \\alpha $\n",
    "\n",
    "Step - 5.1: ? tailed z-test: $$ reject \\ H_0 \\ if \\ ? $$\n",
    "\n",
    "Step - 5.2: Compute p-value"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "15.098999999999998"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "l = [14.08,14.13,15.65,13.78,16.26,14.97,15.36,15.81,14.53,16.79,15.78,16.98,13.23,15.43,15.46,13.88,14.31,14.41,15.76,15.38]\n",
    "\n",
    "sum(l)/len(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "sample_size = 20\n",
    "sample_mean = 15.1\n",
    "pop_mean = 15\n",
    "pop_std = 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.4472135954999564\n"
     ]
    }
   ],
   "source": [
    "z = z_score(sample_size, sample_mean, pop_mean, pop_std)\n",
    "\n",
    "print(z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.6448536269514722\n"
     ]
    }
   ],
   "source": [
    "# One Tail\n",
    "\n",
    "confidence_level = 0.95\n",
    "\n",
    "alpha = 1 - confidence_level\n",
    "\n",
    "z_critical = norm.ppf(1 - alpha)\n",
    "\n",
    "print(z_critical)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(15.1, 0.1, 'x_bar')"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAD4CAYAAAAD6PrjAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAoX0lEQVR4nO3de3hU933n8fdXd3QHJAQIzEUgAtjcIpPYOPiSJsGxHddpNjVxmzabhIc03nafbZM4TdZpkyebbpPtPm1zcWnrepOmdpzWdm0HX9IkBmM3wbK5gyUkwCAJpAGhu4Qu89s/ZkaeCAkNMJpzZubzeh5ZmnN+58xXx5I+/M7vd84x5xwiIiIAGV4XICIi/qFQEBGRUQoFEREZpVAQEZFRCgURERmV5XUB4ykrK3MLFy70ugwRkaTx+uuvn3XOlV/tfnwZCgsXLqS2ttbrMkREkoaZvRWP/ej0kYiIjFIoiIjIKIWCiIiMUiiIiMgohYKIiIxSKIiIyCiFgoiIjPLldQoifhLovsBju08yNBIEIDc7k4+tv4bpBTkeVyYSf5OGgpk9DNwJtDnnrh1n/eeA+6L2txwod861m9kJoBsYAYadczXxKlwkUT7/r/v4RV0As9Br5+DNM9387ea13hYmMgViOX30CLBpopXOuW8659Y459YAXwR2OOfao5rcGl6vQJCk86tj5/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7F3HvX6eE5ao0+OJcBvAG8655omWH9lxzIRo+dRo+GPEureDhH6Y/BJ4N8IHdD9wDNAZbjtXGB71LYfBOoJjaZ/yW81Ehrh3xf+ODSVNU5U55j1JwjPjvDqWF5NnX44nsAPgAPh/+9PA3P8eDxjqdMnxzMH+Ofw79IbwG1eHs8rrdEPxzK8/BFg65i2V30sdZsLEREZ5fnpIxER8Q+FgoiIjFIoiIjIKIWCiIiMUiiIiMgohYKIiIxSKIiIyKj/D4RyBQjSQAD4AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "x_min = 13\n",
    "x_max = 17\n",
    "\n",
    "mean = pop_mean\n",
    "std = pop_std / (sample_size**0.5)\n",
    "\n",
    "x = np.linspace(x_min, x_max, 100)\n",
    "y = norm.pdf(x, mean, std)\n",
    "\n",
    "plt.xlim(x_min, x_max)\n",
    "# plt.ylim(0, 0.03)\n",
    "\n",
    "plt.plot(x, y)\n",
    "\n",
    "z_critical_right = pop_mean + (z_critical * std)\n",
    "\n",
    "x1 = np.linspace(z_critical_right, x_max, 100)\n",
    "y1 = norm.pdf(x1, mean, std)\n",
    "plt.fill_between(x1, y1, color='orange')\n",
    "\n",
    "plt.scatter(sample_mean, 0)\n",
    "plt.annotate(\"x_bar\", (sample_mean, 0.1))\n",
    "\n",
    "# In this case sample mean falls in the acceptance region\n",
    "# i.e. Fail to Reject the Null Hypothesis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Fail to reject Null Hypothesis\n"
     ]
    }
   ],
   "source": [
    "if(z > z_critical):\n",
    "    print(\"Reject Null Hypothesis\")\n",
    "else:\n",
    "    print(\"Fail to reject Null Hypothesis\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "p_value =  0.32736042300928914\n",
      "Fail to reject Null Hypothesis\n"
     ]
    }
   ],
   "source": [
    "p_value = 1.0 - norm.cdf(np.abs(z))\n",
    "\n",
    "print(\"p_value = \", p_value)\n",
    "\n",
    "if(p_value < alpha):\n",
    "    print(\"Reject Null Hypothesis\")\n",
    "else:\n",
    "    print(\"Fail to reject Null Hypothesis\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<b>Q-4: You have developed a new Machine Learning Application and claim that on average it takes less than 100 ms to predict for any future datapoint. How do you convince your client about this claim? (Based on past data you know that the std is 10 ms)</b>\n",
    "\n",
    "Step - 1:  \n",
    "Alternate Hypothesis (Bold Claim): $$ H_1: \\ ? $$\n",
    "Null Hypothesis (Status Quo): $$ H_0: \\ ? $$\n",
    "\n",
    "Step - 2:  \n",
    "* Collect a sample of size n = 100\n",
    "* Compute sample mean $$ \\bar{x} \\ = \\ 97.5 $$\n",
    "\n",
    "Step - 3:\n",
    "Compute Test Statistic: $$ z = \\frac{\\bar{x} - \\mu}{\\sigma/\\sqrt[2]{n}}$$\n",
    "\n",
    "Step - 4:\n",
    "Decide $ \\alpha $\n",
    "\n",
    "Step - 5.1: ? tailed z-test: $$ reject \\ H_0 \\ if \\ ? $$\n",
    "\n",
    "Step - 5.2: Compute p-value"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "sample_size = 100\n",
    "sample_mean = 97.5\n",
    "pop_mean = 100\n",
    "pop_std = 10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-2.5\n"
     ]
    }
   ],
   "source": [
    "z = z_score(sample_size, sample_mean, pop_mean, pop_std)\n",
    "\n",
    "print(z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2.3263478740408408\n"
     ]
    }
   ],
   "source": [
    "# One Tail\n",
    "\n",
    "confidence_level = 0.99\n",
    "\n",
    "alpha = 1 - confidence_level\n",
    "\n",
    "z_critical = norm.ppf(1 - alpha)\n",
    "\n",
    "print(z_critical)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(97.5, 0.02, 'x_bar')"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD4CAYAAADiry33AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAt9UlEQVR4nO3deXyT15no8d8jeTcGgzfALGYHE9YYQgOBQEICSRpImiYw3dsMQ9q0ndvb3qYzvdNOO51p2t7bmd5Jm9K0TdN2SpNp0tAC2dlCFmwIOxiM2Qx4Y7GNjRdJz/1DMiiOjWWw/Wp5vp+PIr3ve4706I14fHR03nNEVTHGGBO9XE4HYIwxpmdZojfGmChnid4YY6KcJXpjjIlyluiNMSbKxTkdQHsyMzM1Ly/P6TCMMSZibN++vVpVs9o7FpaJPi8vj6KiIqfDMMaYiCEixzs6Zl03xhgT5SzRG2NMlLNEb4wxUc4SvTHGRLmQEr2ILBKRYhEpEZHHrlJuhoh4ReSBrtY1xhjTMzpN9CLiBp4AFgP5wHIRye+g3OPAy12ta4wxpueE0qKfCZSoaqmqNgOrgSXtlPsi8Ceg8hrqGmOM6SGhjKPPBU4GbZcBNwUXEJFc4D5gATCjK3WDnmMFsAJg2LBhIYRlTO84cKaWl/aW0zqlt8sl3DN5MKOz+zgcmTGhCSXRSzv72k5i/+/A11XVK/K+4qHU9e9UXQWsAigoKLBJ8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with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "x_min = 95\n",
    "x_max = 105\n",
    "\n",
    "mean = pop_mean\n",
    "std = pop_std / (sample_size**0.5)\n",
    "\n",
    "x = np.linspace(x_min, x_max, 100)\n",
    "y = norm.pdf(x, mean, std)\n",
    "\n",
    "plt.xlim(x_min, x_max)\n",
    "# plt.ylim(0, 0.03)\n",
    "\n",
    "plt.plot(x, y)\n",
    "\n",
    "z_critical_left = pop_mean + (-z_critical * std)\n",
    "\n",
    "x1 = np.linspace(x_min, z_critical_left, 100)\n",
    "y1 = norm.pdf(x1, mean, std)\n",
    "plt.fill_between(x1, y1, color='orange')\n",
    "\n",
    "plt.scatter(sample_mean, 0)\n",
    "plt.annotate(\"x_bar\", (sample_mean, 0.02))\n",
    "\n",
    "# In this case sample mean falls in the rejection region\n",
    "\n",
    "# i.e. Reject Null Hypothesis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Reject Null Hypothesis\n"
     ]
    }
   ],
   "source": [
    "if(z < -z_critical):\n",
    "    print(\"Reject Null Hypothesis\")\n",
    "else:\n",
    "    print(\"Fail to reject Null Hypothesis\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "p_value =  0.006209665325776159\n",
      "Reject Null Hypothesis\n"
     ]
    }
   ],
   "source": [
    "p_value = 1.0 - norm.cdf(np.abs(z))\n",
    "\n",
    "print(\"p_value = \", p_value)\n",
    "\n",
    "if(p_value < alpha):\n",
    "    print(\"Reject Null Hypothesis\")\n",
    "else:\n",
    "    print(\"Fail to reject Null Hypothesis\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Unknown Variance of Population"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<b>Q-1: Pista House selling Hyderabadi Chicken Dum biryani claims that each parcel packet has 500 grams of biryani (also mentioned on the label of packet). You are sceptic of their claims and believe that on average each packet does not contain 500 grams of biryani. How do you prove your claim? ~(Given that the population std is 50)~ </b>\n",
    "\n",
    "<b>Q-2: You have developed a new Natural Language Processing Algorithms and done a user study. You claim that the average rating given by the users is greater than 4 on a scale of 1 to 5. How do you prove this to your client? ~(Given that the population std is 0.5)~ </b>\n",
    "\n",
    "<b>Q-3: TATA has developed a better fuel management system for the SUV segment. They claim that with this system, on average the SUV's mileage is at least 15 km/litre? ~(Given that the population std is 1)~ </b>\n",
    "\n",
    "<b>Q-4: You have developed a new Machine Learning Application and claim that on average it takes less than 100 ms to predict for any future datapoint. How do you convince your client about this claim? ~(Based on past data you know that the std is 10 ms)~ (Assume sample size = 100. For sample mean and sample standard deviation, generate a random sample of 100 data points)</b>\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* <b>Solve all the above mentioned questions in Jupyter Notebook.</b>   \n",
    "* <b>Explain each step and write a proper formated code.</b>    \n",
    "* <b>Use proper variable names in your code.</b>   \n",
    "* <b>Use LaTeX to write scientific formulas.</b>  \n",
    "Refer this link to understand LaTeX format: https://towardsdatascience.com/write-markdown-latex-in-the-jupyter-notebook-10985edb91fd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [],
   "source": [
    "from scipy.stats import t"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.729132811521367\n"
     ]
    }
   ],
   "source": [
    "# One tail\n",
    "\n",
    "confidence_level = 0.95\n",
    "\n",
    "alpha = 1 - confidence_level\n",
    "\n",
    "# For sample size = 20 => degrees of freedom = 20-1 = 19\n",
    "t_critical = t.ppf(1-alpha, df = 19) \n",
    "\n",
    "print(t_critical)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2.093024054408263\n"
     ]
    }
   ],
   "source": [
    "# Two tail\n",
    "\n",
    "alpha = 1 - 0.95\n",
    "\n",
    "t_critical = t.ppf(1-alpha/2, df = 19)\n",
    "\n",
    "print(t_critical)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
